package org.tx.paypal.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.tx.paypal.service.PayPalCheckoutService;
import org.tx.paypal.utils.RequestToMapUtil;

@RestController("/pay")
@Api(description = "PayPalCheckout接口")
public class PayPalCheckoutController {

	@Resource
	private PayPalCheckoutService payPalCheckoutService;

	@ApiOperation(value = "ipn异步回调")
	@PostMapping(value = "/paypal/ipn/back")
	public String callback(HttpServletRequest request, HttpServletResponse response) {
		return payPalCheckoutService.callback(RequestToMapUtil.getParameterMap(request));
	}
}

